fix(sqlite-native): restore native startup kv preload#4639
Conversation
Code ReviewThe PR restores the native startup KV preload that was previously a no-op ( Issues from prior review (still present)
fn startup_preload_put(entries: &mut StartupPreloadEntries, key: &[u8], value: &[u8]) {
if let Ok(idx) = startup_preload_search(entries, key) {
entries[idx].1 = value.to_vec();
}
// Err(_) falls through with no insert
}The no-insert-on-miss behavior is intentional (new pages written at runtime are already durable in KV), but without a comment a reader will assume this is a bug. Add something like:
result.keys.extend(preloaded_keys);
result.values.extend(preloaded_values);The merged result places miss keys first (from the network response), then appends hit keys. Confirm that all callers look up values by key rather than by position. If No integration-level test for the partial-hit/miss merge in The three new unit tests cover helper functions in isolation. Nothing exercises the mixed case: some keys in the preload, some requiring a network fetch. A test with a mock New itemsVersion metadata is encoded, transmitted, then dropped
.map(|entry| (entry.key.to_vec(), entry.value.to_vec()))If the VFS preload never needs versions this is fine, but the round-trip cost (base64-encode in Rust, base64-decode in JS, then dropped) is wasted work. Either stop encoding the version field in
Mutex poison silently turns write-through updates into no-ops fn update_startup_preload(&self, f: impl FnOnce(&mut StartupPreloadEntries)) {
if let Ok(mut guard) = self.startup_preload.lock() { ... }
// Err (poisoned) silently falls through
}If a panic occurs while the lock is held, all subsequent Minor nit
|
12c0baa to
61b5457
Compare
db38027 to
32f2924
Compare
61b5457 to
bc7e3d7
Compare
2b4d526 to
bd95874
Compare
bd95874 to
ebe7c80
Compare
acf0da5 to
492ff0c
Compare
ebe7c80 to
10901e6
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: